package com.laoda.ikun_food.controller.admin.rest;

import com.laoda.ikun_food.service.UserService;
import com.laoda.ikun_food.entity.User;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

@RestController
@AllArgsConstructor
@RequestMapping("/api/admin")
public class UserHomeRestController {
    private UserService userService;

    @GetMapping("/userHome")
    public User showuser(@RequestParam(name = "id", required = false,defaultValue = "1") Integer id){
        return userService.getById(id);
    }

    @GetMapping("/useralt")
    public User showuseralt(@RequestParam(name = "id", required = false,defaultValue = "1") Integer id){
        return userService.getById(id);
    }

    @PostMapping("/userhome/saveOrUpdate")
    public String saveOrUpdateuser(@RequestBody User user){
        userService.saveOrUpdate(user);
        return "ok";
    }
}
